package cn.holy.app.xcddt.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * Created by 69568 on 2018/2/24.
 */

public class StringUtil {
    /**
     * 格式化时间展示为05’10”
     */
    public static String formatRecordTime(long recTime, long maxRecordTime) {
        int time = (int) ((maxRecordTime - recTime) / 1000);
        int minute = time / 60;
        int second = time % 60;
        //return String.format("%2d’%2d”", minute, second);
        return String.format("%2d:%2d", minute, second);
    }


    public static String createdRecordNo(int record_num, int user_id) {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
        String dateString = formatter.format(currentTime);
        Random random = new Random();
        int randomNumber = random.nextInt(999) % (999 - 100 + 1) + 100;
        return dateString + randomNumber + "_" + user_id + "_" + record_num;
    }


    public static String formatTime(int recTime) {
        int time = (recTime / 1000);
        int minute = time / 60;
        int second = time % 60;
        String timestr = "";
        if (minute < 10) {
            timestr = "0" + minute + ":";
        } else {
            timestr = minute + ":";
        }
        if (second < 10) {
            timestr = timestr + "0" + second;
        } else {
            timestr = timestr + second;
        }
        return timestr;
    }


}